package com.song.JavaThread_day04.ch4_5;

import java.util.concurrent.Callable;

public class TaskValidator implements Callable<String> {
	
	private UserValidator validator;
	private String user;
	private String passwd;
	
	
	
	public TaskValidator(UserValidator validator, String user, String passwd) {
		super();
		this.validator = validator;
		this.user = user;
		this.passwd = passwd;
	}

	@Override
	public String call() throws Exception {
		
		if(!validator.validate(user, passwd)){
			System.out.printf(" %s : the user has not been found \n" ,validator.getName());
//			throw new Exception("Error validating user");
		}
		System.out.printf(" %s : the user has been found \n" ,validator.getName());
		return validator.getName();
	}

}
